package com.anhuanjia.tools.eao.controller;

import com.anhuanjia.tools.eao.bean.EaoBuildingContent;
import com.anhuanjia.tools.eao.bean.EaoDepartment;
import com.anhuanjia.tools.eao.bean.EaoProductionEquipment;
import com.anhuanjia.tools.eao.bean.EaoProjectDoc;
import com.anhuanjia.tools.eao.bean.EaoProjectInfo;
import com.anhuanjia.tools.eao.bean.EaoPublicProject;
import com.anhuanjia.tools.eao.bean.EaoSensitivePoints;
import com.anhuanjia.tools.eao.bean.EaoSurroundCompany;
import com.efastsoft.framework.UIFacade;
import com.efastsoft.framework.annotation.Alias;
import com.efastsoft.framework.annotation.Priv;
import com.efastsoft.framework.annotation.Priv.LoginType;
import com.efastsoft.framework.data.DataTable;
import com.efastsoft.framework.data.Q;
/**
 * @ClassName: SceneInvestigationUI
 * @Description: 显示现场勘查信息
 * @author wangqiangqiang
 * @date 2018年9月21日下午5:50:43
 *
 */
@Alias(value = "sceneInvestigation")
public class SceneInvestigationUI extends UIFacade{
	
	@Priv(loginType = LoginType.Member)
	public void selectSceneInvestigation(){
		//当前登录人id
		String id= $V("Id");
		//获取登录人所属类型
		DataTable typeDt=new Q("select * from eao_department ").where().in("UserId", id).fetch();
		EaoDepartment department=new EaoDepartment();
		if(typeDt.getRowCount()!=0) {
			department.setValue(typeDt.get(0));
		}
		//基本信息表
		EaoProjectInfo info=new EaoProjectInfo();
		//这里用项目表中联系人字段作为登录人的id
		DataTable infoDt=new Q("select * from eao_project_info").where().in("Linkman", id).fetch();
		if(infoDt.getRowCount()!=0){
			info.setValue(infoDt.get(0));
		}
		//项目资料表
		EaoProjectDoc doc=new EaoProjectDoc();
		DataTable docDt=new Q("select * from eao_project_doc ").where().in("ProjectId", info.getId()).fetch();
		if(docDt.getRowCount()!=0){
			doc.setValue(docDt.get(0));
		}
		//建设内容表
		EaoBuildingContent buildingContent=new EaoBuildingContent();
		DataTable buildingDt=new Q("select * from eao_building_content ").where().in("ProjectId", info.getId()).fetch();
		if(buildingDt.getRowCount()!=0){
			buildingContent.setValue(buildingDt.get(0));
		}
		//公共工程
		EaoPublicProject publicProject=new EaoPublicProject();
		DataTable publicProjectDt=new Q("select * from eao_public_project ").where().in("ProjectId", info.getId()).fetch();
		if(publicProjectDt.getRowCount()!=0){
			publicProject.setValue(publicProjectDt.get(0));
		}
		//生产设备
		EaoProductionEquipment equipment=new EaoProductionEquipment();
		DataTable equipmentDt=new Q("select * from eao_production_equipment ").where().in("ProjectId", info.getId()).fetch();
		if(equipmentDt.getRowCount()!=0){
			equipment.setValue(equipmentDt.get(0));
		}
        //周围敏感
		EaoSensitivePoints points=new EaoSensitivePoints();
		DataTable pointsDt=new Q("select * from eao_sensitive_points ").where().in("ProjectId", info.getId()).fetch();
		if(pointsDt.getRowCount()!=0){
			points.setValue(pointsDt.get(0));
		}
		//周围公司
		EaoSurroundCompany company=new EaoSurroundCompany();
		DataTable companyDt=new Q("select * from eao_surround_company ").where().in("project_id", info.getId()).fetch();
		if(companyDt.getRowCount()!=0){
			company.setValue(companyDt.get(0));
		}
		$S("type",department.getType());
		$S("info",info);
		$S("doc",doc);
		$S("buildingContent",buildingContent);
		$S("publicProject",publicProject);
		$S("equipment",equipment);
		$S("points",points);
		$S("company",company);
	}
}
